home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / snpd0493.zip / CANT.C < prev    next >
C/C++ Source or Header  |  1993-04-05  |  469b  |  23 lines

  1. /*
  2. **  CANT.C - An fopen() replacement with error trapping
  3. **
  4. **  public domain by Bob Stout
  5. **
  6. **  Call just as you would fopen(), but make sure your exit functions are
  7. **  registered with atexit().
  8. */
  9.  
  10. #include <stdio.h>
  11.  
  12. FILE *cant(char *fname, char *fmode)
  13. {
  14.       FILE *fp;
  15.  
  16.       if (NULL == (fp = fopen(fname, mode)))
  17.       {
  18.             fprintf(stderr, "Can't open %s\n", fname);
  19.             exit(EXIT_FAILURE);
  20.       }
  21.       return fp;
  22. }
  23.